package cn.tedu.charging.common.web;

import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;

@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class JsonResult<T> {
//    状态码
    private Integer code;
//    提示消息
    private String msg;
//    具体的数据
    private  T data;

    //正常返回 入参有数据和消息
    public static  JsonResult ok(Object data,String msg){
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode(2000);
        jsonResult.setData(data);
        jsonResult.setMsg(msg);
        return  jsonResult;
    }

    //正常返回 入参只有数据
    public static JsonResult ok(Object data){
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode(2000);
        jsonResult.setData(data);
        return jsonResult;
    }

}
